<template>
	<view style="padding-bottom:40rpx;">
		<view class="bg">
			<view class="mode" style="color: #666666;line-height: 60rpx;margin-bottom:20rpx;">
				<view style="font-size: 32rpx;font-weight: bold;">
					用户信息
				</view>
				<view>
					下单人：{{info.nickname || ''}}
				</view>
				<view>
					付款人：{{info.payNickname || ''}}
				</view>
			</view>
			<view class="mode" style="color: #666666;line-height: 60rpx;margin:20rpx auto;">
				<view style="font-size: 32rpx;font-weight: bold;">
					订单信息

					<u-button size="mini" class="order-status" type="primary" v-if="info.status<4"
						@click="end(info)">结束订单</u-button>
					<u-button size="mini" class="order-status" type="success" v-else>已完成</u-button>

				</view>
				<view>
					订单编号：{{info.outTradeNo || ''}}
				</view>
				<view>
					门店：{{info.storeName || ''}}
				</view>
				<view>
					台位：{{info.carportName || ''}}
				</view>
				<view>
					消费时长：{{info.minute || 0}}分钟
				</view>
				<view>订单金额：￥{{info.totalMoney || 0}}</view>
				<view>支付余额：￥{{info.balance || 0}}</view>
				<view>支付现金：￥{{info.payMoney || 0}}</view>
				<view>创建时间：￥{{info.payTime || ''}}</view>
				<view>支付时间：￥{{info.payPayTime || ''}}</view>
			</view>

			<view class="mode" style="color: #666666;line-height: 60rpx;margin-top:20rpx;">
				<view style="font-size: 32rpx;font-weight: bold;">
					优惠信息
				</view>
				<view>优惠金额：￥{{info.saleMoney}}</view>
				<view v-if="info.memberCouponId.length">优惠券：{{info.memberCouponId.length || 0}}张</view>
				<view v-if="info.mca">会员卡：{{info.mca.cardName || ''}}</view>
				<view v-if="info.mca">免费时长：{{info.mca.freeTime || 0}}分钟</view>
				<view v-if="info.mca">来源：{{info.mca.source || ''}}</view>
			</view>

		</view>


	</view>
</template>

<script>
	import wxpay from '@/common/wxpay.js';
	export default {
		data() {
			return {
				id: 0,
				info: {}
			}
		},
		methods: {
			end(item) {
				this.$u.post('/indent/orderFinish', {
					order_id: item.id
				}).then(res => {
					if (!res) {
						this.$refs.uToast.show({
							title: '付款成功',
							type: 'success'
						})
					} else if (!Array.isArray(res)) {
						const wx = new wxpay(res);
						wx.pay().then(res => {
							this.$refs.uToast.show({
								title: '付款成功',
								type: 'success'
							})
						}).catch(err => {

						})
					}

				}).catch(err => {
					/* console.log(err)
					if(err.data.code==500){
						this.$refs.uToast.show({
							title: '付款成功',
							type: 'success',
							callback: () => {
								uni.navigateBack()
							}
						})
					} */
				})
			},
			getDetail() {
				this.$u.post('/indent/orderDetail', {
					order_id: this.id
				}).then(res => {
					console.log(res);
					this.info = res;
				}).catch(err => {})
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id
				this.getDetail();
			}
		}
	}
</script>

<style>
	.bg {
		width: 750rpx;
		height: 200rpx;
		background: linear-gradient(-5deg, #0064C6, #2190FB);
		display: inline-block;
		padding-bottom: 40rpx;
	}

	.mode {
		width: 695rpx;

		background: #FFFFFF;
		box-shadow: 6rpx 8rpx 8rpx 1rpx rgba(201, 201, 201, 0.19);
		border-radius: 12rpx;
		background: #FFFFFF;
		margin: 80rpx auto;
		padding: 30rpx;
	}

	.order-status {
		float: right;
	}
</style>